package com.jetpack_sunflower.data


class PlantRespository private constructor(private val plantDao: PlantDao) {

    /**
     * fun getPlants() = plantDao.getPlants()

    fun getPlant(plantId: String) = plantDao.getPlant(plantId)

    fun getPlantsWithGrowZoneNumber(growZoneNumber: Int) =
    plantDao.getPlantsWithGrowZoneNumber(growZoneNumber)
     */

    fun getPlants() = plantDao.getPlants()

    fun getPlant(plantId: String) = plantDao.getPlant(plantId)

    fun getPlantsWithGrowZoneNumber(growZoneNumber: Int) = plantDao.getPlantsWithGrowZoneNumber(growZoneNumber)


    companion object {
        @Volatile
        private var instance: PlantRespository? = null

        fun getInstance(plantDao: PlantDao): PlantRespository {
            return instance ?: synchronized(this) {
                instance ?: PlantRespository(plantDao)
                        .also {
                            instance = it
                        }
            }
        }
    }
}